package com.hllxd.hism.star.exception;

import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

@Getter
public class Result<T> extends BaseResponse {

    public Result(String code, String msg, boolean success, String traceID, T data) {
        this.code = (code == null ? "001" : code);
        this.message = "";
        this.success = success;
        this.traceID = (traceID == null ? StringUtils.EMPTY : traceID);
        this.data = (data == null ? new JSONObject() : data);
    }

    public Result(String code, String msg, String traceID, T data) {
        this(code, msg, "000".equals(code), traceID, data);
    }

    public Result(String code, String msg, boolean success, String traceID) {
        this(code, msg, success, traceID, null);
    }

    public Result(String code, String traceID, T data) {
        this(code, null, traceID, data);
    }

    public Result(String code, T data) {
        this(code, null, "0", data);
    }
}
